import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '../views/controlCenter/layout/layout'

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Home', // 首页
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'HomeIndex', // 首页
      component: () => import('@/views/home/index')
    },
    {
      path: '/regist',
      name: 'AccountRegist', // 注册账号
      component: () => import('@/views/account/regist')
    },
    {
      path: '/forgot',
      name: 'AccountForgot', // 忘记密码
      component: () => import('@/views/account/forgot')
    },
    {
      path: '/document',
      name: 'DocumentIndex', // 文档中心
      component: () => import('@/views/document/index')
    },
    {
      path: '/ST/apply',
      name: 'STApply', // ST板卡申请
      component: () => import('@/views/other/apply')
    },
    {
	    path: '/control',
	    component: Layout,
	    redirect: '/dashboard',
	    name: 'Control', //控制中心
	    children: [
        {
          path: 'dashboard',
          name: 'DashboardPreview',
          redirect: '/dashboard',
          component: () => import('@/views/controlCenter/dashboard/index'),
          meta: {
            title: '监测/概览',
            path: '/control/dashboard',
          },
          children: [
            {
              path: '/',
              name: 'dashboard',
              component: () => import('@/views/controlCenter/dashboard/index'),
            }
          ]
        },
        {
          path: 'devices',
          redirect: '/devices/device',
          component:() => import('@/views/controlCenter/deviceManage/base'),
          name: 'DeviceManage',
          meta: {
            title: '设备管理',
            path: '',
          },
          children: [
            {
              path: '/',
              name: 'Device',
              redirect: '/device',
              component: () => import('@/views/controlCenter/deviceManage/device/base'),
              meta: {
                title: '设备',
                path: '/control/devices/device',
              },
              children: [
                {
                  path: 'device',
                  name: 'DeviceList',
                  component: () => import('@/views/controlCenter/deviceManage/device/list'),
                  meta: {
                    title: '设备列表',
                    path: '',
                  },
                },
                {
                  path: 'device/detail/:id',
                  name: 'DeviceDetail',
                  // redirect: '/detail',
                  component: () => import('@/views/controlCenter/deviceManage/device/detail/detail'),
                  meta: {
                    title: '设备详情',
                    path: '',
                  },
                  // children: [
                  //   {
                  //     path: 'detail/:id',
                  //     name: 'DeviceDetail',
                  //     component: () => import('@/views/controlCenter/deviceManage/device/detail/detail'),
                  //     // meta: {
                  //     //   title: '设备详情',
                  //     //   path: '/control/devices/device/detail/:id',
                  //     // },
                  //   },
                  //   {
                  //     path: 'detail/:id/log',
                  //     name: 'DeviceAppLog',
                  //     component: () => import('@/views/controlCenter/deviceManage/device/detail/app/components/log'),
                  //     meta: {
                  //       title: '应用日志',
                  //       path: '',
                  //     },
                  //   }
                  // ]
                },
                {
                  path: 'device/system/:id',
                  name: 'systemparameter',
                  component: () => import('@/views/controlCenter/deviceManage/device/detail/system/parameter'),
                  meta: {
                    title: '批量操作',
                    path: '',
                  },
                },
                {
                  path: 'device/operation/:ids',
                  name: 'DeviceOperation',
                  component: () => import('@/views/controlCenter/deviceManage/device/detail/operation/operation'),
                  meta: {
                    title: '批量操作',
                    path: '',
                  },
                },
                {
                  path: 'device/log/:batch',
                  name: 'DeviceLog',
                  component: () => import('@/views/controlCenter/deviceManage/device/detail/log/log'),
                  meta: {
                    title: '日志',
                    path: '',
                  },
                },
                {
                  path: 'device/applog',
                  name: 'DeviceAppLog',
                  component: () => import('@/views/controlCenter/deviceManage/device/detail/app/components/log'),
                  meta: {
                    title: '应用日志',
                    path: '',
                  },
                }
              ]
            },{
              path: '/',
              name: 'Group',
              redirect: '/group',
              component: () => import('@/views/controlCenter/deviceManage/group/base'),
              meta: {
                title: '分组',
                path: '/control/devices/group',
              },
              children: [
                {
                  path: 'group',
                  name: 'GroupList',
                  component: () => import('@/views/controlCenter/deviceManage/group/list'),
                  meta: {
                    title: '分组列表',
                    path: '',
                  },
                },
                {
                  path: 'group/detail/:id',
                  name: 'GroupDetail',
                  component: () => import('@/views/controlCenter/deviceManage/group/detail/detail'),
                  meta: {
                    title: '分组详情',
                    path: '',
                  },
                },
              ]
            }
          ]
        },
        {
          path: 'apps',
          name: 'AppManage',
          redirect: '/apps/private',
          component: () => import('@/views/controlCenter/appManage/base'),
          meta: {
            title: '应用管理',
            path: '',
          },
          children: [
            {
              path: '/',
              name: 'Private',
              redirect: '/private',
              component: () => import('@/views/controlCenter/appManage/private/base'),
              meta: {
                title: '个人应用',
                path: '/control/apps/private',
              },
              children: [
                {
                  path: 'private',
                  name: 'PrivateList',
                  component: () => import('@/views/controlCenter/appManage/private/list'),
                  meta: {
                    title: '应用列表',
                    path: '',
                  },
                },
                {
                  path: 'private/detail/:id',
                  name: 'PrivateDetail',
                  component: () => import('@/views/controlCenter/appManage/private/detail'),
                  meta: {
                    title: '应用详情',
                    path: '',
                  },
                },
              ]
            },{
              path: '/',
              name: 'Public',
              redirect: '/public',
              component: () => import('@/views/controlCenter/appManage/public/base'),
              meta: {
                title: '应用商店',
                path: '/control/apps/public',
              },
              children: [
                {
                  path: 'public',
                  name: 'PublicList',
                  component: () => import('@/views/controlCenter/appManage/public/list'),
                  meta: {
                    title: '应用列表',
                    path: '',
                  },
                },
                {
                  path: 'public/detail/:id',
                  name: 'PublicDetail',
                  component: () => import('@/views/controlCenter/appManage/public/detail'),
                  meta: {
                    title: '应用详情',
                    path: '',
                  },
                },
              ]
            },{
              path: '/',
              name: 'Application',
              redirect: '/application',
              component: () => import('@/views/controlCenter/appManage/public/base'),
              meta: {
                title: '应用类型',
                path: '/control/apps/application',
              },
              children: [
                {
                  path: 'application',
                  name: 'ApplicationList',
                  component: () => import('@/views/controlCenter/appManage/application/list'),
                  meta: {
                    title: '应用列表',
                    path: '',
                  },
                },
                // {
                //   path: 'public/detail/:id',
                //   name: 'PublicDetail',
                //   component: () => import('@/views/controlCenter/appManage/public/detail'),
                //   meta: {
                //     title: '应用详情',
                //     path: '',
                //   },
                // },
              ]
            }
            
          ]
        },
        {
          path: 'visual',
          name: 'VisualManage',
          redirect: '/visual/page',
          component: () => import('@/views/controlCenter/visualManage/base'),
          meta: {
            title: '可视化管理',
            path: '',
          },
          children: [
            {
              path: '/',
              name: 'Page',
              redirect: '/page',
              component: () => import('@/views/controlCenter/visualManage/page/base'),
              meta: {
                title: '可视化页面',
                path: '/control/visual/page',
              },
              children: [
                {
                  path: 'page',
                  name: 'PageList',
                  component: () => import('@/views/controlCenter/visualManage/page/list'),
                  meta: {
                    title: '可视化页面列表',
                    path: '',
                  },
                },
              ]
            },
            {
              path: '/',
              name: 'Type',
              redirect: '/type',
              component: () => import('@/views/controlCenter/visualManage/type/base'),
              meta: {
                title: '可视化类型',
                path: '/control/visual/type',
              },
              children: [
                {
                  path: 'type',
                  name: 'TypeList',
                  component: () => import('@/views/controlCenter/visualManage/type/list'),
                  meta: {
                    title: '可视化类型列表',
                    path: '',
                  },
                },
              ]
            }
          ]
        },
        {
          path: 'block',
          name: 'BlockManage',
          redirect: '/block/page',
          component: () => import('@/views/controlCenter/blockManage/base'),
          meta: {
            title: '区块链管理',
            path: '',
          },
          children: [
            {
              path: '/',
              name: 'Chain',
              redirect: '/chain',
              component: () => import('@/views/controlCenter/blockManage/page/base'),
              meta: {
                title: '区块链',
                path: '/control/block/chain',
              },
              children: [
                {
                  path: 'chain',
                  name: 'ChainList',
                  component: () => import('@/views/controlCenter/blockManage/page/list'),
                  meta: {
                    title: '区块链列表',
                    path: '',
                  },
                },
                {
                  path: 'chain/log',
                  name: 'ChainLog',
                  component: () => import('@/views/controlCenter/blockManage/page/detail/log/log'),
                  meta: {
                    title: '日志',
                    path: '',
                  },
                },
              ]
            }
          ]
        },
        {
          path: 'user',
          name: 'User',
          redirect: '/user',
          component: () => import('@/views/controlCenter/user/base'),
          meta: {
            title: '个人账户',
            path: '/control/user',
          },
          children: [
            {
              path: '/',
              name: 'Index',
              component: () => import('@/views/controlCenter/user/index'),
            },
            {
              path: 'order',
              name: 'Order',
              component: () => import('@/views/controlCenter/user/components/buyOrder'),
              meta: {
                title: '购买记录',
                path: '',
              },
            },
            {
              path: 'invoice',
              name: 'Invoice',
              component: () => import('@/views/controlCenter/user/components/buyInvoice'),
              meta: {
                title: '发票记录',
                path: '',
              },
            }
          ]
        },
      ]
		},
    {
      path: '/scan',
      name: 'Scan', // 注册账号
      component: () => import('@/views/scan/index')
    },
    { path: '/404', component: () => import('@/views/404'), hidden: true },
    { path: '*', redirect: '/404', hidden: true }
  ]
})
